#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QTimer>
#include <errno.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <linux/i2c-dev.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "read_thread.h"


#define AM2321_ADDR (0xb8 >> 1)
#define DEV1 "/dev/i2c-2"
#define uart ""

typedef struct ht
{
    float temp;     //temperature
    float humi;        //humidity
}am2321;

#define DS1307_ADDR 0x68
#define DEV2 "/dev/i2c-0"
typedef struct time
{
    uint8_t sec;
    uint8_t min;
    uint8_t hou;
    uint8_t dayOfWeek;
    uint8_t dayOfMonth;
    uint8_t month;
    uint8_t year;
}Time;


namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    void am2321_wake(int fd);
    am2321 am2321_read(int fd);
    Time ds1307_readtime(int fd);
    uint8_t bcd2dec(uint8_t val);

private slots:
    void onTimer();


private:
    Ui::MainWindow *ui;
     int fd1;
     int fd2;
     QTimer *timer1;
     read_thread * thread;

};

#endif // MAINWINDOW_H
